using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace QuadTerrain
{
    class Camera
    {
        public float Pitch = 0f;
        public float Yaw = 0f;
        public float Roll = 0f;

        public int ScreenWidth = 800;
        public int ScreenHeight = 600;

        public float cameraX = 0f;
        public float cameraY = 0f;
        public float cameraZ = 0f;

        public float aspectRatio;


        public Matrix camRotMatrix;
        public Matrix projectionMatrix;
        public Matrix viewMatrix;
        public Matrix worldMatrix;

        public float nearClipPlane = .1f;
        public int farClipPlane = 20000;

        public float FOV = 45.0f;

        public Vector3 cameraPosition = new Vector3(0.0f, 0.0f, -20f);
        public Vector3 cameraDirection = new Vector3(1.0f, 0.0f, 0.0f);


        public void Updatecamera()
        {
            camRotMatrix = Matrix.CreateFromYawPitchRoll(Yaw, Pitch, Roll);
            cameraDirection = camRotMatrix.Forward;
            viewMatrix = Matrix.CreateLookAt(cameraPosition, cameraPosition + cameraDirection, Vector3.Up);
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(FOV), aspectRatio, nearClipPlane, farClipPlane);
            worldMatrix = Matrix.Identity * viewMatrix * projectionMatrix;
        }
    }
}
